<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <canvas id="c1" width="600" height="400"></canvas>

    <script>
        /** @type {HTMLCanvasElement} */
        // 画布
        let c1 = document.getElementById("c1")
        // 画笔
        let ctx = c1.getContext("2d")

        let img = new Image()
        img.src = "./img/money.png"
        img.onload = function () {
            // 创建图案对象
            // 重复方式 repeat no-repeat repeat-x repeat-y
            let pattern = ctx.createPattern(img, "repeat-y")
            // 印章作为填充样式
            ctx.fillStyle = pattern
            ctx.fillRect(0, 0, 600, 400)
        }

    </script>
</body>

</html>